<div class="right-submenu">
	<ul>
		<li><a href="/" title="{"MAIN_PAGE"|i18n}">{"MAIN_PAGE"|i18n}</a></li>
		<li class="last"><span>{$sp.0->name}</span></li>
	</ul>
</div>
<div style="display :none;" id="actionmessage"></div>

<h1>{$sp.0->name}</h1>
{$sp.0->content}
<br><br>

<div id="form_consultation">
	<table class="sendemail">
		<tbody>
			<tr>
				<td></td>
				<td class="formrules"><span class="gh">{"MANDATORY_FIELDS"|i18n|strip_tags|stripslashes}.</span></td>
			</tr>
			<tr><td><label for="form_fio">{"FORM_NAME"|i18n|strip_tags|stripslashes}*</label></td><td><input type="text" class="text" value="" id="form_fio"></td></tr>
			<tr><td><label for="form_email">{"FORM_EMAIL"|i18n|strip_tags|stripslashes}*</label></td><td><input type="text" class="text" value="" id="form_email"></td></tr>
			<tr><td><label for="form_phone">{"FORM_PHONE"|i18n|strip_tags|stripslashes}*</label></td><td><input type="text" class="text" value="" id="form_phone"></td></tr>
			<tr><td><label for="form_age">{"FORM_AGE"|i18n|strip_tags|stripslashes}</label></td><td><input type="text" class="text" value="" id="form_age"></td></tr>
			<tr><td><label for="form_comment">{"FORM_COMMENT"|i18n|strip_tags|stripslashes}*</label></td><td><textarea class="text" id="form_comment"></textarea></td></tr>		
			<tr><td></td><td><input type="button" value="{"CONSULTATION"|i18n|strip_tags|stripslashes}" class="text" id="add_consultation"></td></tr>
		</tbody>
	</table>
</div>

{literal}
<script>
$("#form_phone").mask("+38(099) 999-9999");
$("#add_consultation").click(function(){
	$(this).attr("disabled","disabled");
	$.post(
		"/ajaxcall/addconsultation",
		{
			form_fio: $("#form_fio").val(),
			form_email: $("#form_email").val(),
			form_phone: $("#form_phone").val(),
			form_age: $("#form_age").val(),
			form_comment: $("#form_comment").val(),
		},
		success
	);
	function success(data, textStatus, jqxhr){
		result = $.parseJSON(jqxhr.getResponseHeader('actionmessage'));
		if (result.type == 'success'){
			$('#form_consultation').html(result.message);
			$("#actionmessage").removeClass().addClass(result.type).empty().html(result.message).show("slow");
			setTimeout('$("#actionmessage").hide("slow");', 3000);
		}
		else{
			$("#actionmessage").removeClass().addClass(result.type).empty().html(result.message).show("slow");
			setTimeout('$("#actionmessage").hide("slow");$("#add_consultation").removeAttr("disabled");', 3000);
		}
	}
});

</script>
{/literal}